<?php
    $modal_enabled = $modal_enabled ?? false;
    if ($modal_enabled && $modal_requested) {
        $layout_name = 'modal.phtml';
    } elseif ($current_user && !$current_user->isBlocked()) {
        $layout_name = 'connected.phtml';
    } elseif ($current_user) {
        $layout_name = 'connected_blocked.phtml';
    } else {
        $layout_name = 'not_connected.phtml';
    }

    $default_back_options = [
        'title' => $title,
        'reset' => false,
        'track' => true,
    ];
    $back_options = $back_options ?? [];
    $back_options = array_merge($default_back_options, $back_options);

    $default_search_options = [
        'enabled' => false,
        'query' => '',
    ];
    $search_options = $search_options ?? [];
    $search_options = array_merge($default_search_options, $search_options);

    $this->layout($layout_name, [
        // The title can be considered as safe since it's already sanitized in
        // the calling view.
        'title' => $this->safe('title'),
        'current_tab' => $current_tab ?? null,
        'current_page' => $current_page ?? null,
        'canonical' => $this->safe('canonical'),
        'alternates' => $alternates ?? [],
        'open_graph' => $open_graph ?? [],
        'back_options' => $back_options,
        'search_options' => $search_options,
        'has_errors' => $has_errors ?? false,
    ]);

    echo $this->safe('content');
?>
